<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>用户管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
</head>

<body>
<div id="wrap">
    <div id="top_content">
        <div id="header">
            <div id="rightheader"><p id="current_time"><br/></p></div>
            <div id="topheader">
                <h1 id="title">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="adhomepage.html">首页
                </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="modifyScore.html">评分
                </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="scoreCount.html">成绩统计</a>
                </h1>
            </div>
            <div id="navigation"></div>
        </div>
        <div id="content">
            <p id="whereami">
            </p>
            <h1>评分等级:</h1>
            <table cellpadding="0" cellspacing="0" border="0" class="form_table">
                <tr>
                    <td valign="middle" align="right">学号:</td>
                    <td valign="middle" align="left"><input type="text" class="inputgri" id="code" readonly/></td>
                </tr>
                <tr>
                    <td valign="middle" align="right">参赛学员:</td>
                    <td valign="middle" align="left">
                        <input type="text" class="inputgri" id="name" readonly/>
                    </td>
                </tr>
                <tr>
                    <td valign="middle" align="right">参赛项目:</td>
                    <td valign="middle" align="left">
                        <input type="text" class="inputgri" id="event" readonly/>
                    </td>
                </tr>
                <tr>
                    <td valign="middle" align="right">分数:</td>
                    <td valign="middle" align="left">
                        <input type="text" class="inputgri" id="score" placeholder="请输入0~100内的值"/>
                    </td>
                </tr>
            </table>
            <p><input type="button" class="button" value="确定" onclick="sendModification()"/></p>
        </div>
    </div>
    <div id="footer">
        <div id="footer_bg">ABC@126.com</div>
    </div>
</div>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">
    $("#current_time").text(new Date().toLocaleDateString());

    let id = window.location.href.split("=")[1];

    fillContent(id);

    function fillContent(id) {
        let code = $("#code");      // 学号
        let name = $("#name");      // 姓名
        let event = $("#event");    // 项目名称
        let score = $("#score");    // 分数

        $.post({
            url: "/event/scoring",
            data: {
                "id": id,
            }, success(data) {
                console.log(data);
                code.val(data.username);
                name.val(data.name);
                event.val(data.college);
                score.val(data.major);
            }
        });
    }

    function sendModification() {
        let score = $("#score").val();
        if (score > 100 || score < 0) {
            alert("无效的分数");
        } else {
            $.get({
                url: "/event/addScore",
                data: {
                    "id": id,
                    "franction": score
                }, success(data) {
                    alert(data.message);
                    window.location.href = "adhomepage.html"
                }
            });
        }

    }
</script>
</body>
</html>
